import pandas as pd
import numpy as np
from pandas import Series

m = pd.read_excel('movie.xlsx')
m = m[m.MovieName != '其他']
g = m.groupby(m.month.str[:4])
g.boxoffice.sum()
g.boxoffice.sum() / m.boxoffice.sum()
g1 = m.groupby('MovieName')
g1.size().sort_values(ascending=False)[:10]

print(g)
print(g.boxoffice.sum())
print(g.boxoffice.sum() / m.boxoffice.sum())

s = Series(np.arange(5), index=[list('xxyyx'), list('rbrbb')])
g = s.groupby(level=0)
g.size()
g.agg(lambda x: (x.max(), x.min()))

print(s)
print(g)
print(g.size())
print(g.agg(lambda x: (x.max(), x.min())))
